#include <iostream>
#include <vector>
#include <algorithm>

bool cmp(std::string a, std::string b)
{
    return a + b > b + a;
}

int main()
{
    std::vector<std::string> num_vec;
    int N;
    std::cin >> N;
    for (int i = 0; i < N; i++)
    {
        int number;
        std::cin >> number;
        num_vec.push_back(std::to_string(number));
    }

    std::sort(num_vec.begin(), num_vec.end(), cmp);

    std::string output;
    for (int i = 0; i < N; i++)
    {
        output += num_vec[i];
    }

    if (output[0] == '0')
        std::cout << 0 << std::endl;
    else
        std::cout << output << std::endl;

    return 0;
}